<?php

/* list of tables, fields and types
 * types can be
 *  - KEY_AI: primary key, of type integer, with auto_increment
 *  - KEY#type: primary key, with given type
 *  - string#length: a string of maximum length
 *  - string#length#value1,value2,value3: a string of maximum length, with 3 possible values
 *  - string#length#*table*field*join_field*join_table_field: string, with possible values taken from table.field, with join_field=table.join_table_field
 *  - id#table#field: an id referencing the given field from the given table
 *  - int: integer
 *  - int#min,max: integer with minimum and maximum values
 *  - int#min,max#string1,string2,string3: integer with min and max, and for each value between min and max a string corresponding to the value
 *  - date
 *  - time
 *  - bool
 *  - double
 */
global $app_fields;
$app_fields = array(
    "applicant" => array(
        "applicant_id" => "KEY_AI",
        "applicant_selection_id" => "string#4",
        "applicant_firstname" => "string#20",
        "applicant_lastname" => "string#20",
        "applicant_khmer_name" => "string#50",
        "sex" => "string#1#M,F",
        "applicant_origin_province_id" => "id#province#province_id",
        "applicant_parents_province_id" => "id#province#province_id",
        "ngo_id" => "id#ngo#ngo_id",
        "applicant_date_birth" => "date",
        "applicant_age" => "int",
        "high_school_id" => "id#high_school#high_school_id",
        "comments" => "string#100",
        "excluded" => "bool",
        "excluded_reason" => "string#100",
        "selection_campaign_id" => "id#selection_campaign#selection_campaign_id",
    ),
    "applicant_interest" => array(
        "applicant_id" => "id#applicant#applicant_id",
        "program_id" => "id#program#program_id",
        "interested" => "bool",
    ),
    "applicant_exam_room_beta" => array(
        "applicant_id" => "KEY#int",
        "exam_center_id" => "id#exam_center#exam_center_id",
        "exam_id" => "id#exam#exam_id",
        "room_number" => "string#10#*exam_center_rooms*room*exam_center_id*exam_center_id",
    ),
    "applicant_more_info" => array(
        "applicant_id" => "KEY#int",
        "applicant_more_info_attendee_exam_status" => "int#0,4#Not yet,Yes,No,Partially,Cheat",
        "applicant_interview_attendance" => "int#0,2#Not yet,Yes,No",
        "family_revenue" => "double",
        "family_expense" => "double",
        "family_members" => "int",
        "number_of_married_and_seperated_member" => "int",
        "number_of_children_only_living_in_family" => "int",
        "farming_land_owned" => "string#200",
        "properties_owned" => "string#200",
        "animal_owned" => "string#200",
    ),
    "ngo" => array(
        "ngo_id" => "KEY_AI",
        "ngo_name" => "string#50"
    ),
    "province" => array(
        "province_id" => "KEY_AI",
        "province_name" => "string#29"
    ),
    "high_school" => array(
        "high_school_id" => "KEY_AI",
        "high_school_name" => "string#50"
    ),
    "exam_center" => array(
        "exam_center_id" => "KEY_AI",
        "exam_center_name" => "string#50",
        "province_id" => "id#province#province_id",
        "selection_campaign_id" => "id#selection_campaign#selection_campaign_id",
    ),
    "exam_center_rooms" => array(
        "exam_center_id" => "id#exam_center#exam_center_id",
        "room" => "string#10",
        "capacity" => "int",
    ),
    "exam" => array(
        "exam_id" => "KEY_AI",
        "exam_center_id" => "id#exam_center#exam_center_id",
        "selection_campaign_id" => "id#selection_campaign#selection_campaign_id",
        "exam_date" => "date",
        "exam_start_time" => "time",
        "exam_end_time" => "time",
    ),
    "selection_campaign" => array(
        "selection_campaign_id" => "KEY_AI",
        "selection_campaign_name" => "string#50"
    ),
    "program" => array(
        "program_id" => "KEY_AI",
        "program_name" => "string#20",
    ),
    "selection_campaign_programs" => array(
        "selection_campaign_id" => "id#selection_campaign#selection_campaign_id",
        "program_id" => "id#program#program_id",
    ),
    "staff" => array(
        "username" => "KEY#string#50",
        "password" => "string#50",
        "first_name" => "string#30",
        "last_name" => "string#30",
        "department_id" => "id#department#department_id",
    ),
    "department" => array(
        "department_id" => "KEY_AI",
        "department_name" => "string#50",
    ),
    "staff_roles" => array(
        "username" => "string#50",
        "role" => "string#50",
    ),
    "subject" => array(
        "subject_id" => "KEY_AI",
        "subject_name" => "string#50",
        "global_mark" => "double",
        "selection_campaign_id" => "id#selection_campaign#selection_campaign_id"
    ),
    "subject_part" => array(
        "subject_part_id" => "KEY_AI",
        "subject_part_name" => "string#50",
        "subject_part_number" => "int",
        "subject_part_mark" => "double",
        "subject_part_nb_questions" => "int",
        "subject_id" => "id#subject#subject_id",
    ),
    "exam_copie" => array(
        "exam_copie_id" => "KEY_AI",
        "exam_copie_name" => "string#50",
        "selection_campaign_id" => "id#selection_campaign#selection_campaign_id"
    ),
    "exam_copie_content" => array(
        "exam_copie_id" => "id#exam_copie#exam_copie_id",
        "exam_copie_part_number" => "int",
        "exam_copie_subject_part_id" => "id#subject_part#subject_part_id",
    ),
    "applicant_score_part_exam" => array(
        "applicant_id" => "id#applicant#applicant_id",
        "subject_part_id" => "id#subject_part#subject_part_id",
        "score_part_exam" => "double",
    ),
    "applicant_score_subject_exam" => array(
        "applicant_id" => "id#applicant#applicant_id",
        "subject_id" => "id#subject#subject_id",
        "score_subject_exam" => "double",
        "subject_version" => "string#1",
        "copie" => "int",
    ),
    "exam_eligibility_rule" => array(
        "exam_eligibility_rule_id" => "KEY_AI",
        "program_id" => "id#program#program_id",
        "selection_campaign_id" => "id#selection_campaign#selection_campaign_id",
        "type" => "int#0,1#Minimum Mark,Threshold",
        "mark" => "double",
        "apply_to_high_school_id" => "id#high_school#high_school_id", // null if all
        "apply_to_ngo_id" => "id#ngo#ngo_id", // null if all
    ),
    "exam_eligibility_rule_subjects" => array(
        "exam_eligibility_rule_id" => "id#exam_eligibility_rule#exam_eligibility_rule_id",
        "subject_id" => "id#subject#subject_id",
    ),
    "applicant_eligibility" => array(
        "applicant_id" => "id#applicant#applicant_id",
        "program_id" => "id#program#program_id",
        "eligible" => "bool",
    ),
    "supervisor" => array(
        "exam_id" => "id#exam#exam_id",
        "room" => "string#10",
        "supervisor_username" => "string#50",
    ),
    "concurrency" => array(
        "operation" => "string#100",
        "object_id" => "int",
        "timestamp" => "int",
        "username" => "string#50",
    ),
    "interview_center" => array(
        "interview_center_id" => "KEY_AI",
        "interview_center_name" => "string#50",
        "province_id" => "id#province#province_id",
    ),
    "interview_center_rooms" => array(
        "interview_center_id" => "id#interview_center#interview_center_id",
        "room" => "string#10",
    ),
    "interview" => array(
        "interview_id" => "KEY_AI",
        "interview_date" => "date",
        "interview_start_time" => "time",
        "interview_end_time" => "time",
        "selection_campaign_id" => "id#selection_campaign#selection_campaign_id",
        "interview_center_id" => "id#interview_center#interview_center_id",
        "room" => "string#10",
        "interviewer_username" => "string#50",
    ),
    "interview_observer" => array(
        "interview_id" => "id#interview#interview_id",
        "observer_username" => "string#50",
    ),
    "applicant_interview" => array(
        "applicant_id" => "id#applicant#applicant_id",
        "interview_center_id" => "id#interview_center#interview_center_id",
        "interview_id" => "id#interview#interview_id",
        "interview_type" => "id#program#program_id",
        "interview_communication_and_maturity" => "int#0,5#0,1,2,3,4,5",
        "interview_motivation_for_cist" => "int#0,5#0,1,2,3,4,5",
        "interview_affinities_with_computer_or_carear_plan" => "int#0,5#0,1,2,3,4,5"
    ),
    "interview_eligibility_rule" => array(
        "interview_eligibility_rule_id" => "KEY_AI",
        "program_id" => "id#program#program_id",
        "selection_campaign_id" => "id#selection_campaign#selection_campaign_id",
        "interview_communication_and_maturity_rule" => "int#0,5#0,1,2,3,4,5",
        "interview_motivation_for_cist_rule" => "int#0,5#0,1,2,3,4,5",
        "interview_affinities_with_computer_or_carear_plan_rule" => "int#0,5#0,1,2,3,4,5",
    ),
);
$db_primary = array(
    "applicant_interview" => "applicant_id",
);
$db_indexes = array(
    "applicant" => array("selection_campaign_id"),
    "applicant_eligibility" => array("applicant_id"),
    "applicant_interest" => array("applicant_id"),
    "applicant_score_part_exam" => array("applicant_id"),
    "applicant_score_subject_exam" => array("applicant_id"),
);
$db_unique_multiple_columns = array(
    "applicant_score_part_exam" => array("applicant_id", "subject_part_id"),
    "applicant_score_subject_exam" => array("applicant_id", "subject_id"),
);
?>